﻿#define _CRT_SECURE_NO_WARNINGS 1

int* selfDividingNumbers(int left, int right, int* returnSize)
{
    int* arr = (int*)malloc(sizeof(int) * (right - left + 1));
    if (arr == NULL)
    {
        perror("malloc fail");
        exit(1);
    }
    int t = 0;
    for (int i = left; i <= right; i++)
    {
        int flag = 0;
        int j = i;
        while (j > 0)
        {
            int num = j % 10;
            j /= 10;
            if (num == 0 || i % num != 0)//num==0就可以进入循环了，因为像10这样的就不是自除数了
            {
                flag = 1;
                break;
            }
        }
        if (flag != 1)
        {
            arr[t++] = i;
        }
    }
    *returnSize = t;
    return arr;
}

